import java.io.*;

public class TestSanguo {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        // 1. 打开对象输入流
        ObjectInputStream in = new ObjectInputStream(new FileInputStream("e:/03chenhaisheng/1.txt"));

        // 2. 读取对象
        SanGuo sanguo = (SanGuo)in.readObject();
        System.out.println(sanguo);

        // 3. 关闭文件
        in.close();



        SanGuo sanguo1 = new SanGuo("11","刘备","蜀国",90,85,95);
        SanGuo sanguo2 = new SanGuo("12","曹操","魏国",92,90,95);

        Dog d = new Dog();
        d.name = "小白";
        d.age = 3;


        // 1. 打开流
        ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("e:/03chenhaisheng/1.txt"));

        // 2. 写入数据

        out.writeObject(sanguo1);
        out.writeObject(sanguo2);

        // 3. 关闭
        out.close();

    }
}
